feat(buffa): add MessageFullName trait#108
Open
yordis wants to merge 1 commit intoanthropics:mainfrom
Open
Conversation
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
To be extra clear, intentionally opt-out from |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
user.UserCreated). To use abuffa-generated message directly as a domain event. Skipping the usual hand-written mapping layer between "domain type" and "storage type". Callers need that name as a compile-time constant on the type itself. Today it isn't there: the closest surface,ExtensionSet::PROTO_FQN, is bundled with the extension machinery and only emitted when a message opts intounknown_fields=true, which adds a hidden__buffa_unknown_fieldsfield to the struct and forces every struct-literal construction in domain code to trail..Default::default(). Reaching forbuffa::ExtensionSetjust to read the FQN therefore drags in storage and ergonomic costs the caller doesn't want.buffa::MessageFullNameas a standalone trait with a singleconst FULL_NAME: &'static stritem. Kept out ofMessageprecisely so the FQN concern stays orthogonal and adding it doesn't break any hand-writtenimpl Messagein downstream code. Generic call sites import the trait (use buffa::MessageFullName;) and readT::FULL_NAMEat compile time with no runtime indirection, so event stores, type registries, andAnytype-URL construction can dispatch on it instead of maintaining a hand-written match arm per message.ExtensionSet::PROTO_FQNis intentionally left in place to keep this change additive; the two consts are emitted from the sameproto_fqnsource in codegen so they cannot drift, and that invariant is documented at both sites.MessageFullName/FULL_NAMEmirrors the convention used across the protobuf ecosystem (and matches protocolbuffers/protobuf#27111 to keep the two PRs aligned). Not attached to it. Happy to rename if a different spelling reads better here.Related: TrogonStack/TrogonEventStore#240.